/**
 * This is the class to get the information of the Process
 *
 * @author	Druid YANG, (ADD HERE)
 * @version	0.00, 2008/10/08
 */

package extra.switcher;

import java.awt.Image;

public class ExtraSwitchProcessInfoGetter {
	static { 
		//Used by C++ for Windows API
		//It will load file "prosessinfo.dll"
		System.loadLibrary("prosessinfo");
	}
	
	static ExtraSwitchData CommonSwitchData;

	/*
	 * native function for Windows API
	 * 1 will be returned if no error got;
	 * 0 will be returned if there be any error;
	 * this function will call static function AddData
	 * in order to add information to ExtraSwitchData
	 */
	public native static int getInfoFromAPI(); 
	
	/**
	 * @return true when success,false when error occours 
	 */
	public static boolean getProsessInfo(ExtraSwitchData SwitchData) {
		CommonSwitchData = SwitchData;
		int ReturnValue;
		//Use int in order to easy programming in c++ 
		ReturnValue = getInfoFromAPI();	
		if (ReturnValue==1) return true;
		else return false;
	}
	
	/*
	 *  this mathod will only be called from dll(Windows API)
	 */
	public static boolean AddData(int HANDLE, String WindowTitle, Image Icon, Image FormCaption) {
		//
		return CommonSwitchData.AddProcessInfo(HANDLE, WindowTitle, Icon, FormCaption);
	}
}
